package bufferedStream;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;


public class BufferedStream1 {
	public static void main(String[] args) {
		InputStream is=null;
		OutputStream os=null;
		BufferedInputStream bis=null;
		BufferedOutputStream bos=null;
		try {
			is=new FileInputStream("D:/text.txt");
			os=new FileOutputStream("C:/text.txt");
			bos=new BufferedOutputStream(os);
			bis=new BufferedInputStream(is);
			int b=0;
			while((b=bis.read())!=-1){
				System.out.print((char)b);
				bos.write(b);
				bos.flush();
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if(bis!=null)
				try {
					bis.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			if(bos!=null)
				try {
					bos.close();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		}
	}

}
